/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SMART_SERVE_SERVICES_SERVER_SCHEDULER_EVENT_H
#define SMART_SERVE_SERVICES_SERVER_SCHEDULER_EVENT_H

#include "model/res_config.h"
#include "session/res_config.h"
#include <string>

namespace OHOS {
namespace SmartServe {

enum class EventType {
    SCHEDULE,

    MODEL_APPLIED,
    MODEL_RELEASE,

    SESSION_APPLIED,
    SESSION_RELEASE,

    DEBUG
};

constexpr const char* str(EventType event)
{
    switch (event) {
        case EventType::SCHEDULE:
            return "SCHEDULE";
        case EventType::MODEL_APPLIED:
            return "MODEL_APPLIED";
        case EventType::MODEL_RELEASE:
            return "MODEL_RELEASE";
        case EventType::SESSION_APPLIED:
            return "SESSION_APPLIED";
        case EventType::SESSION_RELEASE:
            return "SESSION_RELEASE";
        case EventType::DEBUG:
            return "DEBUG";
        default:
            return "UNKNOWN";
    }
}

class Event {
public:
    Event(EventType type) : type_(type)
    {}
    virtual ~Event() = default;

    EventType type_;
};

class ScheduleEvent : public Event {
public:
    ScheduleEvent() : Event(EventType::SCHEDULE)
    {}
};

class Model;

class ModelAppliedEvent : public Event {
public:
    ModelAppliedEvent(const ModelResConfig& preConfig, const ModelResConfig& postConfig, bool successful)
        : Event(EventType::MODEL_APPLIED), preConfig_(preConfig), postConfig_(postConfig), successful_(successful)
    {}

    ModelResConfig preConfig_;
    ModelResConfig postConfig_;
    bool successful_;
};

class ModelReleseEvent : public Event {
public:
    ModelReleseEvent(Model* model) : Event(EventType::MODEL_RELEASE), model_(model)
    {}

    Model* model_;
};

class Session;

class SessionAppliedEvent : public Event {
public:
    SessionAppliedEvent(const SessionResConfig& preConfig, const SessionResConfig& postConfig, bool successful)
        : Event(EventType::SESSION_APPLIED), preConfig_(preConfig), postConfig_(postConfig), successful_(successful)
    {}

    SessionResConfig preConfig_;
    SessionResConfig postConfig_;
    bool successful_;
};

class SessionReleseEvent : public Event {
public:
    SessionReleseEvent(Session* session) : Event(EventType::SESSION_RELEASE), session_(session)
    {}

    Session* session_;
};

class DebugEvent : public Event {
public:
    DebugEvent(const std::string& options) : Event(EventType::DEBUG), options_(options)
    {}

    std::string options_;
};

} // namespace SmartServe
} // namespace OHOS

#endif // SMART_SERVE_SERVICES_SERVER_SCHEDULER_EVENT_H
